home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc Development Framework / ODFDev / ODF / Examples / Button / Sources / ButtonSel.cpp < prev    next >
Encoding:
Text File  |  1995-11-08  |  4.4 KB  |  164 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                ButtonSel.cpp
  4. //    Release Version:    $ 1.0d11 $
  5. //
  6. //    Author:                M.Boetcher
  7. //
  8. //    Copyright:    © 1993, 1995 by Apple Computer, Inc., all rights reserved.
  9. //
  10. //========================================================================================
  11.  
  12. #ifndef BUTTONSEL_H
  13. #include "ButtonSel.h"
  14. #endif
  15.  
  16. #ifndef BUTTONPART_H
  17. #include "ButtonPart.h"
  18. #endif
  19.  
  20. #ifndef BUTTONDEF_H
  21. #include "ButtonDef.h"
  22. #endif
  23.  
  24. #ifndef ACTIONS_H
  25. #include "Actions.h"
  26. #endif
  27.  
  28. // ----- Framework Includes -----
  29.  
  30. #ifndef FWPRESEN_H
  31. #include "FWPresen.h"
  32. #endif
  33.  
  34. // ----- OS Layer -----
  35.  
  36. #ifndef FWBARRAY_H
  37. #include "FWBArray.h"
  38. #endif
  39.  
  40. #ifndef FWMEMMGR_H
  41. #include "FWMemMgr.h"
  42. #endif
  43.  
  44. // ----- OpenDoc Includes -----
  45.  
  46. #ifndef SOM_Module_OpenDoc_StdProps_defined
  47. #include <StdProps.xh>
  48. #endif
  49.  
  50. // ----- Macintosh Includes -----
  51.  
  52. #if defined(FW_BUILD_MAC) && !defined(__DRAG__)
  53. #include <Drag.h>
  54. #endif
  55.  
  56. //========================================================================================
  57. //    Runtime information
  58. //========================================================================================
  59.  
  60. #ifdef FW_BUILD_MAC
  61. #pragma segment ButtonPart
  62. #endif
  63.  
  64. //========================================================================================
  65. //    CLASS CButtonSelection
  66. //========================================================================================
  67.  
  68. //----------------------------------------------------------------------------------------
  69. //    CButtonSelection constructor
  70. //----------------------------------------------------------------------------------------
  71.  
  72. CButtonSelection::CButtonSelection(Environment* ev, 
  73.                                 CButtonPart* buttonPart) :
  74.     FW_CSelection(ev, FALSE, FALSE),
  75.     fButtonPart(buttonPart)
  76. {
  77. }
  78.  
  79. //----------------------------------------------------------------------------------------
  80. //    CButtonSelection destructor
  81. //----------------------------------------------------------------------------------------
  82.  
  83. CButtonSelection::~CButtonSelection()
  84. {
  85. }
  86.  
  87. //----------------------------------------------------------------------------------------
  88. //    CButtonSelection::CloseSelection
  89. //----------------------------------------------------------------------------------------
  90.  
  91. void CButtonSelection::CloseSelection(Environment* ev)
  92. {
  93.     // Nothing to do
  94. }
  95.  
  96. //----------------------------------------------------------------------------------------
  97. //    CButtonSelection::ClearSelection
  98. //----------------------------------------------------------------------------------------
  99.  
  100. FW_Boolean CButtonSelection::ClearSelection(Environment* ev)
  101. {
  102.     return FALSE; // Do nothing
  103. }
  104.  
  105. //----------------------------------------------------------------------------------------
  106. //    CButtonSelection::IsEmpty
  107. //----------------------------------------------------------------------------------------
  108.  
  109. FW_Boolean CButtonSelection::IsEmpty(Environment* ev) const
  110. {
  111.     return (fButtonPart->GetAction() == NULL);
  112. }
  113.  
  114. //----------------------------------------------------------------------------------------
  115. //    CButtonSelection::SelectAll
  116. //----------------------------------------------------------------------------------------
  117.  
  118. void CButtonSelection::SelectAll(Environment* ev)
  119. {
  120.     // Nothing to do
  121. }
  122.  
  123. //----------------------------------------------------------------------------------------
  124. //    CButtonSelection::DoExternalizeSelection
  125. //----------------------------------------------------------------------------------------
  126.  
  127. void CButtonSelection::DoExternalizeSelection(
  128.                             Environment* ev, 
  129.                             ODStorageUnit* storage, 
  130.                             FW_CCloneInfo* cloneInfo)
  131. {
  132.     CAction *action = fButtonPart->GetAction();
  133.     if (action)
  134.         action->Externalize(ev, storage);
  135. }
  136.  
  137. //----------------------------------------------------------------------------------------
  138. //    CButtonSelection::DoInternalizeSelection
  139. //----------------------------------------------------------------------------------------
  140.  
  141. FW_Boolean CButtonSelection::DoInternalizeSelection(
  142.                             Environment* ev,
  143.                             ODStorageUnit* storage, 
  144.                             FW_CCloneInfo* cloneInfo)
  145. {
  146.     FW_Boolean internalized = FALSE;
  147.     
  148.     CAction *action = NULL;
  149.     if (CScriptAction::IsInStorage(ev, storage))
  150.         action = new CScriptAction();
  151.     else if (CSoundAction::IsInStorage(ev, storage))
  152.         action = new CSoundAction();
  153.     
  154.     if (action != NULL)
  155.     {
  156.         action->Internalize(ev, storage);
  157.         fButtonPart->SetAction(action);
  158.         fButtonPart->Changed(ev);
  159.         internalized = true;
  160.     }
  161.  
  162.     return internalized;
  163. }
  164.